import fetch from '../fetch.js'
import store from '@/store';
//获取授权信息
const WXauthorization= params=>{
    return fetch({
        url:`/xcx/weixin/authorization`,
        method:'get',
        params:{
            code:params.code
        },
    })
}
//获取微信绑定手机
const WXgetTel= params=>{
    return fetch({
        url:`/xcx/weixin/getTel`,
        method:'get',
        params:{
            encrypdata:params.encrypdata,
            ivdata:params.ivdata,
            sessionkey:params.sessionkey,
        },
    })
}
//密码登陆
const loginByPassword= params=>{
    return fetch({
        url:`/xcx/login/loginByPassword?telphone=`+params.telphone+"&passWord="+params.passWord,
        method:'POST',
        params:{
            telphone:params.telphone,
            passWord:params.passWord,
        },
    })
}
//发送短信
const sendSms= params=>{
    return fetch({
        url:`/xcx/login/sendSms?telphone=`+params.telphone,
        method:'POST',
        params:{
            telphone:params.telphone,
        },
    })
}
//短信登陆
const loginBySms= params=>{
    return fetch({
        url:`/xcx/login/loginBySms?telphone=`+params.telphone+"&smsCode="+params.smsCode,
        method:'POST',
        params:{
            telphone:params.telphone,
            smsCode:params.smsCode,
        },
    })
}
//微信登陆
const loginByWx= params=>{
    return fetch({
        url:`/xcx/login/loginByWx?code=`+params.code,
        method:'POST',
        params:{
            code:params.code
        },
    })
}

//更改密码
const changePassword= c=>{
    return fetch({
        url:`/xcx/user/changePassword?telphone=`+params.telphone+'&passWord='+params.passWord+"&smsCode="+params.smsCode,
        method:'POST',
        params:{
            telphone:params.telphone,
            passWord:params.passWord,
            smsCode:params.smsCode,
        },
    })
}

//注册
const register= params=>{
    var url=`/xcx/user/register?telphone=`+params.telphone
    url+="&passWord="+params.passWord
    url+="&openid="+params.openid
    url+="&smsCode="+params.smsCode
    url+="&nickname="+params.nickname
    url+="&headUrl="+params.headUrl
    return fetch({
        url:url,
        method:'POST',
        params:params
    })
}
//通过uat获取用户信息
const getUserInfo= params=>{
    return fetch({
        url:`/xcx/login/getUserInfo`,
        method:'POST',
    })
}

const userinfo={
    WXauthorization,//获取授权信息
    WXgetTel,//获取微信绑定手机
    loginByPassword,//密码登录
    loginBySms,//短信登陆
    loginByWx,//微信登陆
    sendSms,//发送短信
    changePassword,//更改密码
    register,//注册
    getUserInfo
}

export default userinfo

